package com.rd.student.jiaji.class3.qinjialin.answer;


import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;

public class Quesrion1 {
    public static void main(String[] args) throws IOException {
        ArrayList<Object> arrayList = new ArrayList<>();
        arrayList.add("姓名 语文成绩 数学成绩 总分"+"\n");
        for (int i = 0; i < 3; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入姓名：");
            String name = scanner.next();
            System.out.println("输入语文成绩：");
            int yuwen = scanner.nextInt();
            System.out.println("输入数学成绩：");
            int math = scanner.nextInt();
            Student s = new Student(name, yuwen, math);
            int num = s.num();
            Student ss = new Student(name, yuwen, math, num);
            arrayList.add(ss + "\n");
        }
        File ff = new File("Student.txt");
        Writer wr = new FileWriter(ff);
        wr.write(String.valueOf(arrayList));
        wr.close();


    }

}

class Student {
    String name;
    int yuwen;
    int math;
    int number;

    Student() {

    }

    Student(String name, int yuwen, int math) {
        this.name = name;
        this.math = math;
        this.yuwen = yuwen;
    }

    public int num() {
        int num1 = this.yuwen + this.math;
        return num1;
    }

    Student(String name, int yuwen, int math, int number) {
        this.name = name;
        this.math = math;
        this.yuwen = yuwen;
        this.number = number;

    }

    @Override
    public String toString() {
        return name +"   "+ yuwen +"   "+ math +"   "+ number;
    }
}